package org.dftproject.genesis.ui.figures.zoompan;

import org.dftproject.genesis.ui.pages.pedigree.tree.ScaledGraphicsEx;
import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.ScalableLayeredPane;

public class ScalableLayeredPaneEx extends ScalableLayeredPane {

	@Override
	protected void paintClientArea(Graphics graphics) {
		if (getChildren().isEmpty())
			return;
		if (getScale() == 1.0) {
			super.paintClientArea(graphics);
		} else {
			// Use ScaledGraphicsEx so that round rectangles render well at
			// small scale

			ScaledGraphicsEx g = new ScaledGraphicsEx(graphics);
			boolean optimizeClip = getBorder() == null || getBorder().isOpaque();
			if (!optimizeClip)
				g.clipRect(getBounds().getCropped(getInsets()));
			g.scale(getScale());
			g.pushState();
			paintChildren(g);
			g.dispose();
			graphics.restoreState();
		}
	}

}
